Dynomotion

Group: DynoMotion Message: 5982 From: daveymahomh600e Date: 11/8/2012
Subject: Step by Step
Hello Tom,

A few weeks back I was reading a series of step by step instructions a fellow put together with the intention of helping people like me that are not really strong when it come to electrical problems. I thought it was on CNC Zone but I can't find it. Did you post a link for this somewhere?

I am trying to get my 2 axis SnapAmp system running and most of the tuning stuff is bouncing right off of my brain. I thought that if I read through that posting it would help.

If you know what I am referring to, could you please post a link?

Thanks,
David.
Group: DynoMotion Message: 5984 From: Tom Kerekes Date: 11/8/2012
Subject: Re: Step by Step
Hi David,

Could you be more specific what your problem is?

Maybe:

http://www.cnczone.com/forums/dynomotion_kflop_kanalog/157938-kflop_snapamps.html

or

http://www.cnczone.com/forums/dynomotion_kflop_kanalog/142000-optimizing_servo_tuning.html

Regards
TK


Group: DynoMotion Message: 5985 From: daveymahomh600e Date: 11/8/2012
Subject: Re: Step by Step
Hi Tom,

My main problem is I don't understand most of the elctronic jargon. PWMs, PID, etc. For example, when you helped me with the encoder problem last weekend, I would never have figured out that the encoder had to be set to channel 8. I think the PWM has to be similarly set, but I can't be sure how to do that properly and that gives me a real fear of damaging some sensitive electronic components.

I ran the AutoPhaseFind and recorded the values, but I really don't know where to go next. I entered them the way I thought they should be on the screens, but when I tried a simple move, the servo moved what I presume was the required amount, but then sat there clicking until I disabled the axis. When I ran AutoPhaseFind again, the values were different. So I ran it a third time and so on and got different values each time. In one case the counts per rev are 100000, 30000 for another, and anything in between for the other tests.

I went over the connections to be sure there were no shorts or loose wires, but everything seems correct.

The step by step was written by a fellow that complained the standard documentation was too complex for a non-electrical engineer to follow. I think the last couple of posts he was doubting his ability to finish the help guide because he had overlooked something and was feeling quite dejected about it. You rightfully encouraged him to keep on with it.

I have had a servo connected for three days, but can't figure out what to do next. I know the plots tell the tale, but I can't for the life of me interpret what they are showing. I am reading the KFlopManual.pdf again, but just getting more flustered.

Thanks,
David.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> Could you be more specific what your problem is?
>
> Maybe:
>
> http://www.cnczone.com/forums/dynomotion_kflop_kanalog/157938-kflop_snapamps.html
>
> or
>
> http://www.cnczone.com/forums/dynomotion_kflop_kanalog/142000-optimizing_servo_tuning.html
>
> Regards
> TK
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 10:39 AM
> Subject: [DynoMotion] Step by Step
>
>
>  
> Hello Tom,
>
> A few weeks back I was reading a series of step by step instructions a fellow put together with the intention of helping people like me that are not really strong when it come to electrical problems. I thought it was on CNC Zone but I can't find it. Did you post a link for this somewhere?
>
> I am trying to get my 2 axis SnapAmp system running and most of the tuning stuff is bouncing right off of my brain. I thought that if I read through that posting it would help.
>
> If you know what I am referring to, could you please post a link?
>
> Thanks,
> David.
>
Group: DynoMotion Message: 5988 From: daveymahomh600e Date: 11/8/2012
Subject: Re: Step by Step
Here is the thread I was thinking of...

http://www.cnczone.com/forums/dynomotion_kflop_kanalog/140569-kflop_replacing_lpt_mach3_how-4.html

David

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> Could you be more specific what your problem is?
>
> Maybe:
>
> http://www.cnczone.com/forums/dynomotion_kflop_kanalog/157938-kflop_snapamps.html
>
> or
>
> http://www.cnczone.com/forums/dynomotion_kflop_kanalog/142000-optimizing_servo_tuning.html
>
> Regards
> TK
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 10:39 AM
> Subject: [DynoMotion] Step by Step
>
>
>  
> Hello Tom,
>
> A few weeks back I was reading a series of step by step instructions a fellow put together with the intention of helping people like me that are not really strong when it come to electrical problems. I thought it was on CNC Zone but I can't find it. Did you post a link for this somewhere?
>
> I am trying to get my 2 axis SnapAmp system running and most of the tuning stuff is bouncing right off of my brain. I thought that if I read through that posting it would help.
>
> If you know what I am referring to, could you please post a link?
>
> Thanks,
> David.
>
Group: DynoMotion Message: 5989 From: Tom Kerekes Date: 11/8/2012
Subject: Re: Step by Step
Hi David,

The first requirement is to get the AutoPhaseFind.c test to work reliable.  The test is pretty simple.  It moves the 3-phase brushless motor in a simple manner much like a stepper motor by energizing the coils in sequence.  It then watches the encoder position and the index pulse.  After it sees several index pulses it reverses the motor rotation direction.  So 3 things must work correctly.  The motor must rotate, the encoder must count properly, and the index pulse must work.  You should test the encoder first.  Move the motor/encoder by hand and observe the Position on the Axis Screen.  The position should track the motor/encoder position such that when returning back to the same place the count should be the same.

Regards
TK

Group: DynoMotion Message: 5990 From: daveymahomh600e Date: 11/8/2012
Subject: Re: Step by Step
Hi Tom,

When I turn the encoder by hand, the position readout changes as I would expect. I could also see the AB boxes changing on the digital IO screen, but I didn't see the index pulse show up.

David

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> The first requirement is to get the AutoPhaseFind.c test to work reliable.  The test is pretty simple.  It moves the 3-phase brushless motor in a simple manner much like a stepper motor by energizing the coils in sequence.  It then watches the encoder position and the index pulse.  After it sees several index pulses it reverses the motor rotation direction.  So 3 things must work correctly.  The motor must rotate, the encoder must count properly, and the index pulse must work.  You should test the encoder first.  Move the motor/encoder by hand and observe the Position on the Axis Screen.  The position should track the motor/encoder position such that when returning back to the same place the count should be the same.
>
> Regards
> TK
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 12:03 PM
> Subject: [DynoMotion] Re: Step by Step
>
>
>  
> Hi Tom,
>
> My main problem is I don't understand most of the elctronic jargon. PWMs, PID, etc. For example, when you helped me with the encoder problem last weekend, I would never have figured out that the encoder had to be set to channel 8. I think the PWM has to be similarly set, but I can't be sure how to do that properly and that gives me a real fear of damaging some sensitive electronic components.
>
> I ran the AutoPhaseFind and recorded the values, but I really don't know where to go next. I entered them the way I thought they should be on the screens, but when I tried a simple move, the servo moved what I presume was the required amount, but then sat there clicking until I disabled the axis. When I ran AutoPhaseFind again, the values were different. So I ran it a third time and so on and got different values each time. In one case the counts per rev are 100000, 30000 for another, and anything in between for the other tests.
>
> I went over the connections to be sure there were no shorts or loose wires, but everything seems correct.
>
> The step by step was written by a fellow that complained the standard documentation was too complex for a non-electrical engineer to follow. I think the last couple of posts he was doubting his ability to finish the help guide because he had overlooked something and was feeling quite dejected about it. You rightfully encouraged him to keep on with it.
>
> I have had a servo connected for three days, but can't figure out what to do next. I know the plots tell the tale, but I can't for the life of me interpret what they are showing. I am reading the KFlopManual.pdf again, but just getting more flustered.
>
> Thanks,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi David,
> >
> > Could you be more specific what your problem is?
> >
> > Maybe:
> >
> > http://www.cnczone.com/forums/dynomotion_kflop_kanalog/157938-kflop_snapamps.html
> >
> > or
> >
> > http://www.cnczone.com/forums/dynomotion_kflop_kanalog/142000-optimizing_servo_tuning.html
> >
> > Regards
> > TK
> >
> >
> >
> >
> >
> > ________________________________
> > From: daveymahomh600e <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Thursday, November 8, 2012 10:39 AM
> > Subject: [DynoMotion] Step by Step
> >
> >
> >  
> > Hello Tom,
> >
> > A few weeks back I was reading a series of step by step instructions a fellow put together with the intention of helping people like me that are not really strong when it come to electrical problems. I thought it was on CNC Zone but I can't find it. Did you post a link for this somewhere?
> >
> > I am trying to get my 2 axis SnapAmp system running and most of the tuning stuff is bouncing right off of my brain. I thought that if I read through that posting it would help.
> >
> > If you know what I am referring to, could you please post a link?
> >
> > Thanks,
> > David.
> >
>
Group: DynoMotion Message: 5991 From: Tom Kerekes Date: 11/8/2012
Subject: Re: Step by Step
Hi David,

The index pulse is very narrow.  You will have to position and hold the encoder to an exact position to see it change which is almost impossible to do by hand.  User programs execute every 180us so as long as the pulse is wider than this it will be detected properly.  If the index is never detected the program should rotate forever looking for the index.

Why don't you post some AutoPhaseFind.c reports so we can look at them?  As well as a detailed description of what you observe.

Regards
TK

Group: DynoMotion Message: 5992 From: David Stevenson Date: 11/8/2012
Subject: Re: Step by Step

Hi Tom,
 
Here are 4 reports, which look a lot better than most have...
 
After each report I noted how many turns (revs) the shaft made... so many in one direction and then so many in the opposite direction. I didn't catch the number for the first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000 for a full turn of the shaft.
 
REPORT
------
0 Position =      0 PhaseAngle = 0.416000
1 Position =  10000 PhaseAngle = 2.455000
2 Position =      1 PhaseAngle = 0.197000
3 Position = -109999 PhaseAngle = -21.803000
Counts per rev =  10000
Counts per cycle =   4904
Counts per cycle (rounded)=   4900
invDistPerCycle (rounded)=  0.000204081633
Commutation offset =   2822
Input Gain Specified =  1.000
 
? and 10 turns
 
REPORT
------
0 Position =     -1 PhaseAngle = 0.417000
1 Position = 119999 PhaseAngle = 24.455000
2 Position =  39998 PhaseAngle = 8.196000
3 Position =  19998 PhaseAngle = 4.196000
Counts per rev = 120000
Counts per cycle =   4992
Counts per cycle (rounded)=   4990
invDistPerCycle (rounded)=  0.000200400802
Commutation offset =   2872
Input Gain Specified =  1.000
 
12 and 10 turns
 
REPORT
------
0 Position =      2 PhaseAngle = 0.417000
1 Position =  60001 PhaseAngle = 12.454000
2 Position =  50001 PhaseAngle = 10.198000
3 Position =  30002 PhaseAngle = 6.198000
Counts per rev =  59999
Counts per cycle =   4985
Counts per cycle (rounded)=   4980
invDistPerCycle (rounded)=  0.000200803213
Commutation offset =   2868
Input Gain Specified =  1.000
 
6 and 10 turns
 
REPORT
------
0 Position =      0 PhaseAngle = 0.417000
1 Position =  39999 PhaseAngle = 8.454000
2 Position = -40001 PhaseAngle = -7.802000
3 Position = -60002 PhaseAngle = -11.802000
Counts per rev =  39999
Counts per cycle =   4977
Counts per cycle (rounded)=   4980
invDistPerCycle (rounded)=  0.000200803213
Commutation offset =   2868
Input Gain Specified =  1.000
 
4 and 10 turns
 
Here are the settings I used for the APF.c program...
 
#define PWM_CHAN 8   // which pair of PWM channels used
#define ENCODER_CHAN 8  // which encoder we are connected to
#define ENCODER_GAIN 1   // Set to -1 if desired to reverse axis direction
#define AMPLITUDE 10     // Set how hard to drive the coils pwm counts
#define Z_BIT_NUMBER 66  // What bit the Z index is connected to
#define CLAMP_VOLTAGE 85   // volts - set a few volts higher than your supply
#define AXIS_CHAN 0        // Axis channel to be used and configured
#define Ncycles 4   // don't change this
 
Thank you,
David.
 
 
-----Original Message-----
From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com]On Behalf Of Tom Kerekes
Sent: Thursday, November 08, 2012 6:14 PM
To: DynoMotion@yahoogroups.com
Subject: Re: [DynoMotion] Re: Step by Step

 

Hi David,

The index pulse is very narrow.  You will have to position and hold the encoder to an exact position to see it change which is almost impossible to do by hand.  User programs execute every 180us so as long as the pulse is wider than this it will be detected properly.  If the index is never detected the program should rotate forever looking for the index.

Why don't you post some AutoPhaseFind.c reports so we can look at them?  As well as a detailed description of what you observe.

Regards
TK

Group: DynoMotion Message: 5993 From: Tom Kerekes Date: 11/8/2012
Subject: Re: Step by Step

Hi David,

It looks like the Index is not being detected every time.  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.  It just isn't detected every time.

You might check the wire and voltages.  If one of the + or - signals is not connected the signal can be erratic.  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.

It might be that the pulse is so short that the software loop misses it.  Your encoder is fairly high resolution so the index pulse might be very small. 

Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.  I've attached a modified program that checks every time slice (180us) which is 5X faster.  I've also slowed down the rotation speed about 2X.  Please try that.

Regards
TK

Group: DynoMotion Message: 5994 From: daveymahomh600e Date: 11/8/2012
Subject: Re: Step by Step
Hi Tom,

The new program seems to have cured that issue. Here are 3 reports...

REPORT
------
0 Position = 1 PhaseAngle = 0.390600
1 Position = 10001 PhaseAngle = 2.396800
2 Position = 10002 PhaseAngle = 2.299000
3 Position = 2 PhaseAngle = 0.255400
Counts per rev = 10000
Counts per cycle = 4985
Counts per cycle (rounded)= 4980
invDistPerCycle (rounded)= 0.000200803213
Commutation offset = 2978
Input Gain Specified = 1.000

REPORT
------
0 Position = -1 PhaseAngle = 0.390400
1 Position = 9999 PhaseAngle = 2.397600
2 Position = 10000 PhaseAngle = 2.298800
3 Position = 0 PhaseAngle = 0.255000
Counts per rev = 10000
Counts per cycle = 4982
Counts per cycle (rounded)= 4980
invDistPerCycle (rounded)= 0.000200803213
Commutation offset = 2979
Input Gain Specified = 1.000

REPORT
------
0 Position = -1 PhaseAngle = 0.390500
1 Position = 9999 PhaseAngle = 2.397300
2 Position = 10000 PhaseAngle = 2.298900
3 Position = 0 PhaseAngle = 0.255100
Counts per rev = 10000
Counts per cycle = 4983
Counts per cycle (rounded)= 4980
invDistPerCycle (rounded)= 0.000200803213
Commutation offset = 2979
Input Gain Specified = 1.000

In each case, the motor shaft rotated once in each direction.

Sooo, the next step is....

Thank you very much,
David.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
>
>
> Hi David,
>
> It looks like the Index is not being detected every time.  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.  It just isn't detected every time.
>
> You might check the wire and voltages.  If one of the + or - signals is not connected the signal can be erratic.  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
>
> It might be that the pulse is so short that the software loop misses it.  Your encoder is fairly high resolution so the index pulse might be very small. 
>
>
> Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.  I've attached a modified program that checks every time slice (180us) which is 5X faster.  I've also slowed down the rotation speed about 2X.  Please try that.
>
> Regards
> TK
>
>
>
> ________________________________
> From: David Stevenson <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 4:24 PM
> Subject: RE: [DynoMotion] Re: Step by Step
>
>
>  
> 
> Hi
> Tom,
>  
> Here are 4
> reports, which look a lot better than most have...
>  
> After each
> report I noted how many turns (revs) the shaft made... so many in one direction
> and then so many in the opposite direction. I didn't catch the number for the
> first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> for a full turn of the shaft.
>  
> REPORT
> ------
> 0 Position =      0
> PhaseAngle = 0.416000
> 1 Position =  10000 PhaseAngle = 2.455000
> 2
> Position =      1 PhaseAngle = 0.197000
> 3 Position =
> -109999 PhaseAngle = -21.803000
> Counts per rev =  10000
> Counts per
> cycle =   4904
> Counts per cycle (rounded)=  
> 4900
> invDistPerCycle (rounded)=  0.000204081633
> Commutation offset
> =   2822
> Input Gain Specified =  1.000
>  
> ? and 10
> turns
>  
> REPORT
> ------
> 0 Position =     -1
> PhaseAngle = 0.417000
> 1 Position = 119999 PhaseAngle = 24.455000
> 2
> Position =  39998 PhaseAngle = 8.196000
> 3 Position =  19998
> PhaseAngle = 4.196000
> Counts per rev = 120000
> Counts per cycle
> =   4992
> Counts per cycle (rounded)=  
> 4990
> invDistPerCycle (rounded)=  0.000200400802
> Commutation offset
> =   2872
> Input Gain Specified =  1.000
>  
> 12 and 10
> turns
>  
> REPORT
> ------
> 0 Position =      2
> PhaseAngle = 0.417000
> 1 Position =  60001 PhaseAngle = 12.454000
> 2
> Position =  50001 PhaseAngle = 10.198000
> 3 Position =  30002
> PhaseAngle = 6.198000
> Counts per rev =  59999
> Counts per cycle
> =   4985
> Counts per cycle (rounded)=  
> 4980
> invDistPerCycle (rounded)=  0.000200803213
> Commutation offset
> =   2868
> Input Gain Specified =  1.000
>  
> 6 and 10
> turns
>  
> REPORT
> ------
> 0 Position =      0
> PhaseAngle = 0.417000
> 1 Position =  39999 PhaseAngle = 8.454000
> 2
> Position = -40001 PhaseAngle = -7.802000
> 3 Position = -60002 PhaseAngle =
> -11.802000
> Counts per rev =  39999
> Counts per cycle =  
> 4977
> Counts per cycle (rounded)=   4980
> invDistPerCycle
> (rounded)=  0.000200803213
> Commutation offset =  
> 2868
> Input Gain Specified =  1.000
>  
> 4 and 10
> turns
>  
> Here are
> the settings I used for the APF.c program...
>  
> #define
> PWM_CHAN 8   // which pair of PWM channels used
> #define
> ENCODER_CHAN 8  // which encoder we are connected to
> #define
> ENCODER_GAIN 1   // Set to -1 if desired to reverse axis
> direction
> #define AMPLITUDE 10     // Set how hard to
> drive the coils pwm counts
> #define Z_BIT_NUMBER 66  // What bit the
> Z index is connected to
> #define CLAMP_VOLTAGE 85   // volts - set a
> few volts higher than your supply
> #define
> AXIS_CHAN 0        // Axis channel
> to be used and configured
> #define Ncycles 4   // don't change
> this
>  
> Thank
> you,
> David.
>  
>  
>
Group: DynoMotion Message: 5995 From: Tom Kerekes Date: 11/8/2012
Subject: Re: Step by Step
Hi David,

That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:

invDistPerCycle=0.0002;
Commutationoffset=2987;

Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.

There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).

I think I have made the appropriate changes in the attached file.

Regards
TK




Group: DynoMotion Message: 5998 From: daveymahomh600e Date: 11/9/2012
Subject: Re: Step by Step
Thank you very much Tom.

I will give it a try this morning.

David

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:
>
> invDistPerCycle=0.0002;
> Commutationoffset=2987;
>
>
> Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.
>
> There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).
>
> I think I have made the appropriate changes in the attached file.
>
> Regards
> TK
>
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 5:56 PM
> Subject: [DynoMotion] Re: Step by Step
>
>
>  
> Hi Tom,
>
> The new program seems to have cured that issue. Here are 3 reports...
>
> REPORT
> ------
> 0 Position = 1 PhaseAngle = 0.390600
> 1 Position = 10001 PhaseAngle = 2.396800
> 2 Position = 10002 PhaseAngle = 2.299000
> 3 Position = 2 PhaseAngle = 0.255400
> Counts per rev = 10000
> Counts per cycle = 4985
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2978
> Input Gain Specified = 1.000
>
> REPORT
> ------
> 0 Position = -1 PhaseAngle = 0.390400
> 1 Position = 9999 PhaseAngle = 2.397600
> 2 Position = 10000 PhaseAngle = 2.298800
> 3 Position = 0 PhaseAngle = 0.255000
> Counts per rev = 10000
> Counts per cycle = 4982
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2979
> Input Gain Specified = 1.000
>
> REPORT
> ------
> 0 Position = -1 PhaseAngle = 0.390500
> 1 Position = 9999 PhaseAngle = 2.397300
> 2 Position = 10000 PhaseAngle = 2.298900
> 3 Position = 0 PhaseAngle = 0.255100
> Counts per rev = 10000
> Counts per cycle = 4983
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2979
> Input Gain Specified = 1.000
>
> In each case, the motor shaft rotated once in each direction.
>
> Sooo, the next step is....
>
> Thank you very much,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> >
> >
> > Hi David,
> >
> > It looks like the Index is not being detected every time.  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.  It just isn't detected every time.
> >
> > You might check the wire and voltages.  If one of the + or - signals is not connected the signal can be erratic.  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
> >
> > It might be that the pulse is so short that the software loop misses it.  Your encoder is fairly high resolution so the index pulse might be very small. 
> >
> >
> > Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.  I've attached a modified program that checks every time slice (180us) which is 5X faster.  I've also slowed down the rotation speed about 2X.  Please try that.
> >
> > Regards
> > TK
> >
> >
> >
> > ________________________________
> > From: David Stevenson <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Thursday, November 8, 2012 4:24 PM
> > Subject: RE: [DynoMotion] Re: Step by Step
> >
> >
> >  
> > 
> > Hi
> > Tom,
> >  
> > Here are 4
> > reports, which look a lot better than most have...
> >  
> > After each
> > report I noted how many turns (revs) the shaft made... so many in one direction
> > and then so many in the opposite direction. I didn't catch the number for the
> > first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> > for a full turn of the shaft.
> >  
> > REPORT
> > ------
> > 0 Position =      0
> > PhaseAngle = 0.416000
> > 1 Position =  10000 PhaseAngle = 2.455000
> > 2
> > Position =      1 PhaseAngle = 0.197000
> > 3 Position =
> > -109999 PhaseAngle = -21.803000
> > Counts per rev =  10000
> > Counts per
> > cycle =   4904
> > Counts per cycle (rounded)=  
> > 4900
> > invDistPerCycle (rounded)=  0.000204081633
> > Commutation offset
> > =   2822
> > Input Gain Specified =  1.000
> >  
> > ? and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =     -1
> > PhaseAngle = 0.417000
> > 1 Position = 119999 PhaseAngle = 24.455000
> > 2
> > Position =  39998 PhaseAngle = 8.196000
> > 3 Position =  19998
> > PhaseAngle = 4.196000
> > Counts per rev = 120000
> > Counts per cycle
> > =   4992
> > Counts per cycle (rounded)=  
> > 4990
> > invDistPerCycle (rounded)=  0.000200400802
> > Commutation offset
> > =   2872
> > Input Gain Specified =  1.000
> >  
> > 12 and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =      2
> > PhaseAngle = 0.417000
> > 1 Position =  60001 PhaseAngle = 12.454000
> > 2
> > Position =  50001 PhaseAngle = 10.198000
> > 3 Position =  30002
> > PhaseAngle = 6.198000
> > Counts per rev =  59999
> > Counts per cycle
> > =   4985
> > Counts per cycle (rounded)=  
> > 4980
> > invDistPerCycle (rounded)=  0.000200803213
> > Commutation offset
> > =   2868
> > Input Gain Specified =  1.000
> >  
> > 6 and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =      0
> > PhaseAngle = 0.417000
> > 1 Position =  39999 PhaseAngle = 8.454000
> > 2
> > Position = -40001 PhaseAngle = -7.802000
> > 3 Position = -60002 PhaseAngle =
> > -11.802000
> > Counts per rev =  39999
> > Counts per cycle =  
> > 4977
> > Counts per cycle (rounded)=   4980
> > invDistPerCycle
> > (rounded)=  0.000200803213
> > Commutation offset =  
> > 2868
> > Input Gain Specified =  1.000
> >  
> > 4 and 10
> > turns
> >  
> > Here are
> > the settings I used for the APF.c program...
> >  
> > #define
> > PWM_CHAN 8   // which pair of PWM channels used
> > #define
> > ENCODER_CHAN 8  // which encoder we are connected to
> > #define
> > ENCODER_GAIN 1   // Set to -1 if desired to reverse axis
> > direction
> > #define AMPLITUDE 10     // Set how hard to
> > drive the coils pwm counts
> > #define Z_BIT_NUMBER 66  // What bit the
> > Z index is connected to
> > #define CLAMP_VOLTAGE 85   // volts - set a
> > few volts higher than your supply
> > #define
> > AXIS_CHAN 0        // Axis channel
> > to be used and configured
> > #define Ncycles 4   // don't change
> > this
> >  
> > Thank
> > you,
> > David.
> >  
> >  
> >
Group: DynoMotion Message: 6001 From: daveymahomh600e Date: 11/9/2012
Subject: Re: Step by Step
Hi Tom,

I loaded the HomeBrushless file and ran it. I couldn't tell if anything happened. Should there be any message on the console screen?

I compared this new Homing file to other similar files and am wondering about the program line (43 in Notepad++) "Write3PH(ch4,0,0); // turn off the coil" should that be ch0?

Anyway I ran the file and tried a move command on the Step Response screen and there was motion which ended with the servo twitching back and forth until disabling it. I changed line 43 to ch0 and ran it again and the plots on Step Response looked much more sensible.

I know there is tuning to do, but does this HomeBrushless file get ultimately added to the init file?

Thanks,
David.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:
>
> invDistPerCycle=0.0002;
> Commutationoffset=2987;
>
>
> Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.
>
> There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).
>
> I think I have made the appropriate changes in the attached file.
>
> Regards
> TK
>
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Thursday, November 8, 2012 5:56 PM
> Subject: [DynoMotion] Re: Step by Step
>
>
>  
> Hi Tom,
>
> The new program seems to have cured that issue. Here are 3 reports...
>
> REPORT
> ------
> 0 Position = 1 PhaseAngle = 0.390600
> 1 Position = 10001 PhaseAngle = 2.396800
> 2 Position = 10002 PhaseAngle = 2.299000
> 3 Position = 2 PhaseAngle = 0.255400
> Counts per rev = 10000
> Counts per cycle = 4985
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2978
> Input Gain Specified = 1.000
>
> REPORT
> ------
> 0 Position = -1 PhaseAngle = 0.390400
> 1 Position = 9999 PhaseAngle = 2.397600
> 2 Position = 10000 PhaseAngle = 2.298800
> 3 Position = 0 PhaseAngle = 0.255000
> Counts per rev = 10000
> Counts per cycle = 4982
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2979
> Input Gain Specified = 1.000
>
> REPORT
> ------
> 0 Position = -1 PhaseAngle = 0.390500
> 1 Position = 9999 PhaseAngle = 2.397300
> 2 Position = 10000 PhaseAngle = 2.298900
> 3 Position = 0 PhaseAngle = 0.255100
> Counts per rev = 10000
> Counts per cycle = 4983
> Counts per cycle (rounded)= 4980
> invDistPerCycle (rounded)= 0.000200803213
> Commutation offset = 2979
> Input Gain Specified = 1.000
>
> In each case, the motor shaft rotated once in each direction.
>
> Sooo, the next step is....
>
> Thank you very much,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> >
> >
> > Hi David,
> >
> > It looks like the Index is not being detected every time.  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.  It just isn't detected every time.
> >
> > You might check the wire and voltages.  If one of the + or - signals is not connected the signal can be erratic.  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
> >
> > It might be that the pulse is so short that the software loop misses it.  Your encoder is fairly high resolution so the index pulse might be very small. 
> >
> >
> > Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.  I've attached a modified program that checks every time slice (180us) which is 5X faster.  I've also slowed down the rotation speed about 2X.  Please try that.
> >
> > Regards
> > TK
> >
> >
> >
> > ________________________________
> > From: David Stevenson <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Thursday, November 8, 2012 4:24 PM
> > Subject: RE: [DynoMotion] Re: Step by Step
> >
> >
> >  
> > 
> > Hi
> > Tom,
> >  
> > Here are 4
> > reports, which look a lot better than most have...
> >  
> > After each
> > report I noted how many turns (revs) the shaft made... so many in one direction
> > and then so many in the opposite direction. I didn't catch the number for the
> > first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> > for a full turn of the shaft.
> >  
> > REPORT
> > ------
> > 0 Position =      0
> > PhaseAngle = 0.416000
> > 1 Position =  10000 PhaseAngle = 2.455000
> > 2
> > Position =      1 PhaseAngle = 0.197000
> > 3 Position =
> > -109999 PhaseAngle = -21.803000
> > Counts per rev =  10000
> > Counts per
> > cycle =   4904
> > Counts per cycle (rounded)=  
> > 4900
> > invDistPerCycle (rounded)=  0.000204081633
> > Commutation offset
> > =   2822
> > Input Gain Specified =  1.000
> >  
> > ? and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =     -1
> > PhaseAngle = 0.417000
> > 1 Position = 119999 PhaseAngle = 24.455000
> > 2
> > Position =  39998 PhaseAngle = 8.196000
> > 3 Position =  19998
> > PhaseAngle = 4.196000
> > Counts per rev = 120000
> > Counts per cycle
> > =   4992
> > Counts per cycle (rounded)=  
> > 4990
> > invDistPerCycle (rounded)=  0.000200400802
> > Commutation offset
> > =   2872
> > Input Gain Specified =  1.000
> >  
> > 12 and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =      2
> > PhaseAngle = 0.417000
> > 1 Position =  60001 PhaseAngle = 12.454000
> > 2
> > Position =  50001 PhaseAngle = 10.198000
> > 3 Position =  30002
> > PhaseAngle = 6.198000
> > Counts per rev =  59999
> > Counts per cycle
> > =   4985
> > Counts per cycle (rounded)=  
> > 4980
> > invDistPerCycle (rounded)=  0.000200803213
> > Commutation offset
> > =   2868
> > Input Gain Specified =  1.000
> >  
> > 6 and 10
> > turns
> >  
> > REPORT
> > ------
> > 0 Position =      0
> > PhaseAngle = 0.417000
> > 1 Position =  39999 PhaseAngle = 8.454000
> > 2
> > Position = -40001 PhaseAngle = -7.802000
> > 3 Position = -60002 PhaseAngle =
> > -11.802000
> > Counts per rev =  39999
> > Counts per cycle =  
> > 4977
> > Counts per cycle (rounded)=   4980
> > invDistPerCycle
> > (rounded)=  0.000200803213
> > Commutation offset =  
> > 2868
> > Input Gain Specified =  1.000
> >  
> > 4 and 10
> > turns
> >  
> > Here are
> > the settings I used for the APF.c program...
> >  
> > #define
> > PWM_CHAN 8   // which pair of PWM channels used
> > #define
> > ENCODER_CHAN 8  // which encoder we are connected to
> > #define
> > ENCODER_GAIN 1   // Set to -1 if desired to reverse axis
> > direction
> > #define AMPLITUDE 10     // Set how hard to
> > drive the coils pwm counts
> > #define Z_BIT_NUMBER 66  // What bit the
> > Z index is connected to
> > #define CLAMP_VOLTAGE 85   // volts - set a
> > few volts higher than your supply
> > #define
> > AXIS_CHAN 0        // Axis channel
> > to be used and configured
> > #define Ncycles 4   // don't change
> > this
> >  
> > Thank
> > you,
> > David.
> >  
> >  
> >
Group: DynoMotion Message: 6002 From: Tom Kerekes Date: 11/9/2012
Subject: Re: Step by Step
Hi David,

Nothing should really happen when you run the program except the motor should remain still and not run away.  It should be servoing.  That is if you push the motor by hand it should resist and try to return back to where it was.  The gain is probably very low so the response will be very poor but the idea is to see that functionally it is working.  A good thing to check at this stage is that the commutation is really working properly.  As you push the motor away the motor torque should increase up to the maximum we have set as the MaxOutput Parameter.  If we continue to push the motor further away, for example 2 revs, the torque should remain constant and in the same direction.  If the commutation is not working correctly the torque will vary or even reverse.  It is normal for a motor's torque to vary a bit (~10% torque ripple), but not more than that.

My mistake on the ch4.  You are using ch0 so correct everything should be ch0.  I doubt if that would make any real difference.  It just wouldn't turn off the coil current after finding the index, but as soon as the servo is turned on, the servo will write new coil currents anyway.  I'm not sure why it made a difference for you.

Making a "Move" on the Step Response Screen downloads all axis parameters from the Step, Config, and Filter Screens. So make sure they are all set to reasonable values and match what is in the HomeBrushless.c program.  An easy way to do this is to "Upload" the parameters from KFLOP to the Screens (after running the HomeBrushless.c program).  There is a Flash video that explains the interaction between the various ways to change parameters.  See:

http://www.dynomotion.com/Help/FlashHelp/Parameters/index.html

Plot the Response of a Move and post it so we can see it (one method is to Alt-Print-Screen, paste to Paint.exe, save as *.png file).  If you also save the raw data we can zoom, and plot the data ourselves in various ways.

Don't really worry about the Init.c file at this point, but yes, after everything is working you can make one Init.c file that does everything, configures, enables, phasefinds, homes, etc...  Whatever you wish.

Regards
TK


Group: DynoMotion Message: 6006 From: daveymahomh600e Date: 11/9/2012
Subject: Re: Step by Step
Hi Tom,

I have uploaded a zip file called Response Plots to the file area for all to see.

Thank you,
David.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> Nothing should really happen when you run the program except the motor should remain still and not run away.  It should be servoing.  That is if you push the motor by hand it should resist and try to return back to where it was.  The gain is probably very low so the response will be very poor but the idea is to see that functionally it is working.  A good thing to check at this stage is that the commutation is really working properly.  As you push the motor away the motor torque should increase up to the maximum we have set as the MaxOutput Parameter.  If we continue to push the motor further away, for example 2 revs, the torque should remain constant and in the same direction.  If the commutation is not working correctly the torque will vary or even reverse.  It is normal for a motor's torque to vary a bit (~10% torque ripple), but not more than that.
>
> My mistake on the ch4.  You are using ch0 so correct everything should be ch0.  I doubt if that would make any real difference.  It just wouldn't turn off the coil current after finding the index, but as soon as the servo is turned on, the servo will write new coil currents anyway.  I'm not sure why it made a difference for you.
>
> Making a "Move" on the Step Response Screen downloads all axis parameters from the Step, Config, and Filter Screens. So make sure they are all set to reasonable values and match what is in the HomeBrushless.c program.  An easy way to do this is to "Upload" the parameters from KFLOP to the Screens (after running the HomeBrushless.c program).  There is a Flash video that explains the interaction between the various ways to change parameters.  See:
>
> http://www.dynomotion.com/Help/FlashHelp/Parameters/index.html
>
> Plot the Response of a Move and post it so we can see it (one method is to Alt-Print-Screen, paste to Paint.exe, save as *.png file).  If you also save the raw data we can zoom, and plot the data ourselves in various ways.
>
> Don't really worry about the Init.c file at this point, but yes, after everything is working you can make one Init.c file that does everything, configures, enables, phasefinds, homes, etc...  Whatever you wish.
>
> Regards
> TK
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Friday, November 9, 2012 8:20 AM
> Subject: [DynoMotion] Re: Step by Step
>
>
>  
> Hi Tom,
>
> I loaded the HomeBrushless file and ran it. I couldn't tell if anything happened. Should there be any message on the console screen?
>
> I compared this new Homing file to other similar files and am wondering about the program line (43 in Notepad++) "Write3PH(ch4,0,0); // turn off the coil" should that be ch0?
>
> Anyway I ran the file and tried a move command on the Step Response screen and there was motion which ended with the servo twitching back and forth until disabling it. I changed line 43 to ch0 and ran it again and the plots on Step Response looked much more sensible.
>
> I know there is tuning to do, but does this HomeBrushless file get ultimately added to the init file?
>
> Thanks,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi David,
> >
> > That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:
> >
> > invDistPerCycle=0.0002;
> > Commutationoffset=2987;
> >
> >
> > Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.
> >
> > There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).
> >
> > I think I have made the appropriate changes in the attached file.
> >
> > Regards
> > TK
> >
> >
> >
> >
> >
> >
> > ________________________________
> > From: daveymahomh600e <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Thursday, November 8, 2012 5:56 PM
> > Subject: [DynoMotion] Re: Step by Step
> >
> >
> >  
> > Hi Tom,
> >
> > The new program seems to have cured that issue. Here are 3 reports...
> >
> > REPORT
> > ------
> > 0 Position = 1 PhaseAngle = 0.390600
> > 1 Position = 10001 PhaseAngle = 2.396800
> > 2 Position = 10002 PhaseAngle = 2.299000
> > 3 Position = 2 PhaseAngle = 0.255400
> > Counts per rev = 10000
> > Counts per cycle = 4985
> > Counts per cycle (rounded)= 4980
> > invDistPerCycle (rounded)= 0.000200803213
> > Commutation offset = 2978
> > Input Gain Specified = 1.000
> >
> > REPORT
> > ------
> > 0 Position = -1 PhaseAngle = 0.390400
> > 1 Position = 9999 PhaseAngle = 2.397600
> > 2 Position = 10000 PhaseAngle = 2.298800
> > 3 Position = 0 PhaseAngle = 0.255000
> > Counts per rev = 10000
> > Counts per cycle = 4982
> > Counts per cycle (rounded)= 4980
> > invDistPerCycle (rounded)= 0.000200803213
> > Commutation offset = 2979
> > Input Gain Specified = 1.000
> >
> > REPORT
> > ------
> > 0 Position = -1 PhaseAngle = 0.390500
> > 1 Position = 9999 PhaseAngle = 2.397300
> > 2 Position = 10000 PhaseAngle = 2.298900
> > 3 Position = 0 PhaseAngle = 0.255100
> > Counts per rev = 10000
> > Counts per cycle = 4983
> > Counts per cycle (rounded)= 4980
> > invDistPerCycle (rounded)= 0.000200803213
> > Commutation offset = 2979
> > Input Gain Specified = 1.000
> >
> > In each case, the motor shaft rotated once in each direction.
> >
> > Sooo, the next step is....
> >
> > Thank you very much,
> > David.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > >
> > >
> > > Hi David,
> > >
> > > It looks like the Index is not being detected every time.  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.  It just isn't detected every time.
> > >
> > > You might check the wire and voltages.  If one of the + or - signals is not connected the signal can be erratic.  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
> > >
> > > It might be that the pulse is so short that the software loop misses it.  Your encoder is fairly high resolution so the index pulse might be very small. 
> > >
> > >
> > > Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.  I've attached a modified program that checks every time slice (180us) which is 5X faster.  I've also slowed down the rotation speed about 2X.  Please try that.
> > >
> > > Regards
> > > TK
> > >
> > >
> > >
> > > ________________________________
> > > From: David Stevenson <david.m.stevenson@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Thursday, November 8, 2012 4:24 PM
> > > Subject: RE: [DynoMotion] Re: Step by Step
> > >
> > >
> > >  
> > > 
> > > Hi
> > > Tom,
> > >  
> > > Here are 4
> > > reports, which look a lot better than most have...
> > >  
> > > After each
> > > report I noted how many turns (revs) the shaft made... so many in one direction
> > > and then so many in the opposite direction. I didn't catch the number for the
> > > first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> > > for a full turn of the shaft.
> > >  
> > > REPORT
> > > ------
> > > 0 Position =      0
> > > PhaseAngle = 0.416000
> > > 1 Position =  10000 PhaseAngle = 2.455000
> > > 2
> > > Position =      1 PhaseAngle = 0.197000
> > > 3 Position =
> > > -109999 PhaseAngle = -21.803000
> > > Counts per rev =  10000
> > > Counts per
> > > cycle =   4904
> > > Counts per cycle (rounded)=  
> > > 4900
> > > invDistPerCycle (rounded)=  0.000204081633
> > > Commutation offset
> > > =   2822
> > > Input Gain Specified =  1.000
> > >  
> > > ? and 10
> > > turns
> > >  
> > > REPORT
> > > ------
> > > 0 Position =     -1
> > > PhaseAngle = 0.417000
> > > 1 Position = 119999 PhaseAngle = 24.455000
> > > 2
> > > Position =  39998 PhaseAngle = 8.196000
> > > 3 Position =  19998
> > > PhaseAngle = 4.196000
> > > Counts per rev = 120000
> > > Counts per cycle
> > > =   4992
> > > Counts per cycle (rounded)=  
> > > 4990
> > > invDistPerCycle (rounded)=  0.000200400802
> > > Commutation offset
> > > =   2872
> > > Input Gain Specified =  1.000
> > >  
> > > 12 and 10
> > > turns
> > >  
> > > REPORT
> > > ------
> > > 0 Position =      2
> > > PhaseAngle = 0.417000
> > > 1 Position =  60001 PhaseAngle = 12.454000
> > > 2
> > > Position =  50001 PhaseAngle = 10.198000
> > > 3 Position =  30002
> > > PhaseAngle = 6.198000
> > > Counts per rev =  59999
> > > Counts per cycle
> > > =   4985
> > > Counts per cycle (rounded)=  
> > > 4980
> > > invDistPerCycle (rounded)=  0.000200803213
> > > Commutation offset
> > > =   2868
> > > Input Gain Specified =  1.000
> > >  
> > > 6 and 10
> > > turns
> > >  
> > > REPORT
> > > ------
> > > 0 Position =      0
> > > PhaseAngle = 0.417000
> > > 1 Position =  39999 PhaseAngle = 8.454000
> > > 2
> > > Position = -40001 PhaseAngle = -7.802000
> > > 3 Position = -60002 PhaseAngle =
> > > -11.802000
> > > Counts per rev =  39999
> > > Counts per cycle =  
> > > 4977
> > > Counts per cycle (rounded)=   4980
> > > invDistPerCycle
> > > (rounded)=  0.000200803213
> > > Commutation offset =  
> > > 2868
> > > Input Gain Specified =  1.000
> > >  
> > > 4 and 10
> > > turns
> > >  
> > > Here are
> > > the settings I used for the APF.c program...
> > >  
> > > #define
> > > PWM_CHAN 8   // which pair of PWM channels used
> > > #define
> > > ENCODER_CHAN 8  // which encoder we are connected to
> > > #define
> > > ENCODER_GAIN 1   // Set to -1 if desired to reverse axis
> > > direction
> > > #define AMPLITUDE 10     // Set how hard to
> > > drive the coils pwm counts
> > > #define Z_BIT_NUMBER 66  // What bit the
> > > Z index is connected to
> > > #define CLAMP_VOLTAGE 85   // volts - set a
> > > few volts higher than your supply
> > > #define
> > > AXIS_CHAN 0        // Axis channel
> > > to be used and configured
> > > #define Ncycles 4   // don't change
> > > this
> > >  
> > > Thank
> > > you,
> > > David.
> > >  
> > >  
> > >
Group: DynoMotion Message: 6009 From: Tom Kerekes Date: 11/9/2012
Subject: Re: Step by Step
Hi David,

In the future please provide more info besides just files.  In general: what you did, what happened, what your understanding is, whether or not you performed the tests previously asked, etc...  It just reduces the guesswork on our end and the number of emails to resolve an issue.

But from the plots I see:

#1 motor currents flowing of ~8A through the motor - so I'm assuming it really moved

#2 no encoder position change at all

I see a bug in the C code.  The encoder channel was specified as 4 rather than 8.

change:

    ch0->InputChan0=4;

to

    ch0->InputChan0=8;

Then the Encoder Position should change when the motor moves.

The basic commutation and servo tests would have failed also because of no encoder motion or error.

Regards
TK



Group: DynoMotion Message: 6011 From: daveymahomh600e Date: 11/9/2012
Subject: Re: Step by Step
Hi Tom,

I was focused on uploading the files and neglected to offer any explanation. Sorry.

When I requested a move of 1000 the shaft rotated about 30 degrees (probably 36) in one direction only.

I have since changed the code to correct the input channel, but when I ran the 1000 move after the HomeBrushless, nothing moved. The shaft seems to be pulsing slightly and if I turn it, it jumps about 10 degrees.

Tomorrow I will run the procedure again and post some more plots.

Thanks,
David.

--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi David,
>
> In the future please provide more info besides just files.  In general: what you did, what happened, what your understanding is, whether or not you performed the tests previously asked, etc...  It just reduces the guesswork on our end and the number of emails to resolve an issue.
>
> But from the plots I see:
>
> #1 motor currents flowing of ~8A through the motor - so I'm assuming it really moved
>
> #2 no encoder position change at all
>
>
> I see a bug in the C code.  The encoder channel was specified as 4 rather than 8.
>
> change:
>
>
>     ch0->InputChan0=4;
>
>
> to
>
>     ch0->InputChan0=8;
>
> Then the Encoder Position should change when the motor moves.
>
>
> The basic commutation and servo tests would have failed also because of no encoder motion or error.
>
> Regards
> TK
>
>
>
>
>
> ________________________________
> From: daveymahomh600e <david.m.stevenson@...>
> To: DynoMotion@yahoogroups.com
> Sent: Friday, November 9, 2012 12:35 PM
> Subject: [DynoMotion] Re: Step by Step
>
>
>  
> Hi Tom,
>
> I have uploaded a zip file called Response Plots to the file area for all to see.
>
> Thank you,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi David,
> >
> > Nothing should really happen when you run the program except the motor should remain still and not run away.  It should be servoing.  That is if you push the motor by hand it should resist and try to return back to where it was.  The gain is probably very low so the response will be very poor but the idea is to see that functionally it is working.  A good thing to check at this stage is that the commutation is really working properly.  As you push the motor away the motor torque should increase up to the maximum we have set as the MaxOutput Parameter.  If we continue to push the motor further away, for example 2 revs, the torque should remain constant and in the same direction.  If the commutation is not working correctly the torque will vary or even reverse.  It is normal for a motor's torque to vary a bit (~10% torque ripple), but not more than that.
> >
> > My mistake on the ch4.  You are using ch0 so correct everything should be ch0.  I doubt if that would make any real difference.  It just wouldn't turn off the coil current after finding the index, but as soon as the servo is turned on, the servo will write new coil currents anyway.  I'm not sure why it made a difference for you.
> >
> > Making a "Move" on the Step Response Screen downloads all axis parameters from the Step, Config, and Filter Screens. So make sure they are all set to reasonable values and match what is in the HomeBrushless.c program.  An easy way to do this is to "Upload" the parameters from KFLOP to the Screens (after running the HomeBrushless.c program).  There is a Flash video that explains the interaction between the various ways to change parameters.  See:
> >
> > http://www.dynomotion.com/Help/FlashHelp/Parameters/index.html
> >
> > Plot the Response of a Move and post it so we can see it (one method is to Alt-Print-Screen, paste to Paint.exe, save as *.png file).  If you also save the raw data we can zoom, and plot the data ourselves in various ways.
> >
> > Don't really worry about the Init.c file at this point, but yes, after everything is working you can make one Init.c file that does everything, configures, enables, phasefinds, homes, etc...  Whatever you wish.
> >
> > Regards
> > TK
> >
> >
> >
> >
> >
> > ________________________________
> > From: daveymahomh600e <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Friday, November 9, 2012 8:20 AM
> > Subject: [DynoMotion] Re: Step by Step
> >
> >
> >  
> > Hi Tom,
> >
> > I loaded the HomeBrushless file and ran it. I couldn't tell if anything happened. Should there be any message on the console screen?
> >
> > I compared this new Homing file to other similar files and am wondering about the program line (43 in Notepad++) "Write3PH(ch4,0,0); // turn off the coil" should that be ch0?
> >
> > Anyway I ran the file and tried a move command on the Step Response screen and there was motion which ended with the servo twitching back and forth until disabling it. I changed line 43 to ch0 and ran it again and the plots on Step Response looked much more sensible.
> >
> > I know there is tuning to do, but does this HomeBrushless file get ultimately added to the init file?
> >
> > Thanks,
> > David.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi David,
> > >
> > > That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:
> > >
> > > invDistPerCycle=0.0002;
> > > Commutationoffset=2987;
> > >
> > >
> > > Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.
> > >
> > > There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).
> > >
> > > I think I have made the appropriate changes in the attached file.
> > >
> > > Regards
> > > TK
> > >
> > >
> > >
> > >
> > >
> > >
> > > ________________________________
> > > From: daveymahomh600e <david.m.stevenson@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Thursday, November 8, 2012 5:56 PM
> > > Subject: [DynoMotion] Re: Step by Step
> > >
> > >
> > >  
> > > Hi Tom,
> > >
> > > The new program seems to have cured that issue. Here are 3 reports...
> > >
> > > REPORT
> > > ------
> > > 0 Position = 1 PhaseAngle = 0.390600
> > > 1 Position = 10001 PhaseAngle = 2.396800
> > > 2 Position = 10002 PhaseAngle = 2.299000
> > > 3 Position = 2 PhaseAngle = 0.255400
> > > Counts per rev = 10000
> > > Counts per cycle = 4985
> > > Counts per cycle (rounded)= 4980
> > > invDistPerCycle (rounded)= 0.000200803213
> > > Commutation offset = 2978
> > > Input Gain Specified = 1.000
> > >
> > > REPORT
> > > ------
> > > 0 Position = -1 PhaseAngle = 0.390400
> > > 1 Position = 9999 PhaseAngle = 2.397600
> > > 2 Position = 10000 PhaseAngle = 2.298800
> > > 3 Position = 0 PhaseAngle = 0.255000
> > > Counts per rev = 10000
> > > Counts per cycle = 4982
> > > Counts per cycle (rounded)= 4980
> > > invDistPerCycle (rounded)= 0.000200803213
> > > Commutation offset = 2979
> > > Input Gain Specified = 1.000
> > >
> > > REPORT
> > > ------
> > > 0 Position = -1 PhaseAngle = 0.390500
> > > 1 Position = 9999 PhaseAngle = 2.397300
> > > 2 Position = 10000 PhaseAngle = 2.298900
> > > 3 Position = 0 PhaseAngle = 0.255100
> > > Counts per rev = 10000
> > > Counts per cycle = 4983
> > > Counts per cycle (rounded)= 4980
> > > invDistPerCycle (rounded)= 0.000200803213
> > > Commutation offset = 2979
> > > Input Gain Specified = 1.000
> > >
> > > In each case, the motor shaft rotated once in each direction.
> > >
> > > Sooo, the next step is....
> > >
> > > Thank you very much,
> > > David.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > >
> > > >
> > > > Hi David,
> > > >
> > > > It looks like the Index is not being detected every time.ÃÆ'‚  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.ÃÆ'‚  It just isn't detected every time.
> > > >
> > > > You might check the wire and voltages.ÃÆ'‚  If one of the + or - signals is not connected the signal can be erratic.ÃÆ'‚  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
> > > >
> > > > It might be that the pulse is so short that the software loop misses it.ÃÆ'‚  Your encoder is fairly high resolution so the index pulse might be very small.ÃÆ'‚ 
> > > >
> > > >
> > > > Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.ÃÆ'‚  I've attached a modified program that checks every time slice (180us) which is 5X faster.ÃÆ'‚  I've also slowed down the rotation speed about 2X.ÃÆ'‚  Please try that.
> > > >
> > > > Regards
> > > > TK
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > From: David Stevenson <david.m.stevenson@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Thursday, November 8, 2012 4:24 PM
> > > > Subject: RE: [DynoMotion] Re: Step by Step
> > > >
> > > >
> > > > ÃÆ'‚ 
> > > > ÃÆ'¯Â»Â¿
> > > > Hi
> > > > Tom,
> > > > ÃÆ'‚ 
> > > > Here are 4
> > > > reports, which look a lot better than most have...
> > > > ÃÆ'‚ 
> > > > After each
> > > > report I noted how many turns (revs) the shaft made... so many in one direction
> > > > and then so many in the opposite direction. I didn't catch the number for the
> > > > first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> > > > for a full turn of the shaft.
> > > > ÃÆ'‚ 
> > > > REPORT
> > > > ------
> > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  0
> > > > PhaseAngle = 0.416000
> > > > 1 Position =ÃÆ'‚  10000 PhaseAngle = 2.455000
> > > > 2
> > > > Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  1 PhaseAngle = 0.197000
> > > > 3 Position =
> > > > -109999 PhaseAngle = -21.803000
> > > > Counts per rev =ÃÆ'‚  10000
> > > > Counts per
> > > > cycle =ÃÆ'‚ ÃÆ'‚  4904
> > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > 4900
> > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000204081633
> > > > Commutation offset
> > > > =ÃÆ'‚ ÃÆ'‚  2822
> > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > ÃÆ'‚ 
> > > > ? and 10
> > > > turns
> > > > ÃÆ'‚ 
> > > > REPORT
> > > > ------
> > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  -1
> > > > PhaseAngle = 0.417000
> > > > 1 Position = 119999 PhaseAngle = 24.455000
> > > > 2
> > > > Position =ÃÆ'‚  39998 PhaseAngle = 8.196000
> > > > 3 Position =ÃÆ'‚  19998
> > > > PhaseAngle = 4.196000
> > > > Counts per rev = 120000
> > > > Counts per cycle
> > > > =ÃÆ'‚ ÃÆ'‚  4992
> > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > 4990
> > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000200400802
> > > > Commutation offset
> > > > =ÃÆ'‚ ÃÆ'‚  2872
> > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > ÃÆ'‚ 
> > > > 12 and 10
> > > > turns
> > > > ÃÆ'‚ 
> > > > REPORT
> > > > ------
> > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  2
> > > > PhaseAngle = 0.417000
> > > > 1 Position =ÃÆ'‚  60001 PhaseAngle = 12.454000
> > > > 2
> > > > Position =ÃÆ'‚  50001 PhaseAngle = 10.198000
> > > > 3 Position =ÃÆ'‚  30002
> > > > PhaseAngle = 6.198000
> > > > Counts per rev =ÃÆ'‚  59999
> > > > Counts per cycle
> > > > =ÃÆ'‚ ÃÆ'‚  4985
> > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > 4980
> > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000200803213
> > > > Commutation offset
> > > > =ÃÆ'‚ ÃÆ'‚  2868
> > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > ÃÆ'‚ 
> > > > 6 and 10
> > > > turns
> > > > ÃÆ'‚ 
> > > > REPORT
> > > > ------
> > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  0
> > > > PhaseAngle = 0.417000
> > > > 1 Position =ÃÆ'‚  39999 PhaseAngle = 8.454000
> > > > 2
> > > > Position = -40001 PhaseAngle = -7.802000
> > > > 3 Position = -60002 PhaseAngle =
> > > > -11.802000
> > > > Counts per rev =ÃÆ'‚  39999
> > > > Counts per cycle =ÃÆ'‚ ÃÆ'‚ 
> > > > 4977
> > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚  4980
> > > > invDistPerCycle
> > > > (rounded)=ÃÆ'‚  0.000200803213
> > > > Commutation offset =ÃÆ'‚ ÃÆ'‚ 
> > > > 2868
> > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > ÃÆ'‚ 
> > > > 4 and 10
> > > > turns
> > > > ÃÆ'‚ 
> > > > Here are
> > > > the settings I used for the APF.c program...
> > > > ÃÆ'‚ 
> > > > #define
> > > > PWM_CHAN 8ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // which pair of PWM channels used
> > > > #define
> > > > ENCODER_CHANÃÆ'‚ 8ÃÆ'‚ ÃÆ'‚ // which encoder we are connected to
> > > > #define
> > > > ENCODER_GAIN 1 ÃÆ'‚ ÃÆ'‚ // Set to -1 if desired to reverse axis
> > > > direction
> > > > #define AMPLITUDE 10ÃÆ'‚ ÃÆ'‚  ÃÆ'‚ ÃÆ'‚ // Set how hard to
> > > > drive the coils pwm counts
> > > > #define Z_BIT_NUMBER 66ÃÆ'‚ ÃÆ'‚ // What bit the
> > > > Z index is connected to
> > > > #define CLAMP_VOLTAGE 85ÃÆ'‚  ÃÆ'‚ // volts - set a
> > > > few volts higher than your supply
> > > > #define
> > > > AXIS_CHANÃÆ'‚ 0ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // Axis channel
> > > > to be used and configured
> > > > #define Ncycles 4ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // don't change
> > > > this
> > > > ÃÆ'‚ 
> > > > Thank
> > > > you,
> > > > David.
> > > > ÃÆ'‚ 
> > > > ÃÆ'‚ 
> > > >
Group: DynoMotion Message: 6019 From: daveymahomh600e Date: 11/10/2012
Subject: Re: Step by Step
Hello Tom,

I updated the HomeBrushless file and re-ran it this morning.

This time the motion of the shaft was as expected... about 1/10th turn left, then the same back when I ran a move of 1000 counts.

There is force on the shaft so I expect it is servoing.

The plots and data have been uploaded as file Response Plots 2.zip

Any feedback would be greatly appreciated.

Thank you,
David.

--- In DynoMotion@yahoogroups.com, "daveymahomh600e" <david.m.stevenson@...> wrote:
>
> Hi Tom,
>
> I was focused on uploading the files and neglected to offer any explanation. Sorry.
>
> When I requested a move of 1000 the shaft rotated about 30 degrees (probably 36) in one direction only.
>
> I have since changed the code to correct the input channel, but when I ran the 1000 move after the HomeBrushless, nothing moved. The shaft seems to be pulsing slightly and if I turn it, it jumps about 10 degrees.
>
> Tomorrow I will run the procedure again and post some more plots.
>
> Thanks,
> David.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi David,
> >
> > In the future please provide more info besides just files.  In general: what you did, what happened, what your understanding is, whether or not you performed the tests previously asked, etc...  It just reduces the guesswork on our end and the number of emails to resolve an issue.
> >
> > But from the plots I see:
> >
> > #1 motor currents flowing of ~8A through the motor - so I'm assuming it really moved
> >
> > #2 no encoder position change at all
> >
> >
> > I see a bug in the C code.  The encoder channel was specified as 4 rather than 8.
> >
> > change:
> >
> >
> >     ch0->InputChan0=4;
> >
> >
> > to
> >
> >     ch0->InputChan0=8;
> >
> > Then the Encoder Position should change when the motor moves.
> >
> >
> > The basic commutation and servo tests would have failed also because of no encoder motion or error.
> >
> > Regards
> > TK
> >
> >
> >
> >
> >
> > ________________________________
> > From: daveymahomh600e <david.m.stevenson@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Friday, November 9, 2012 12:35 PM
> > Subject: [DynoMotion] Re: Step by Step
> >
> >
> >  
> > Hi Tom,
> >
> > I have uploaded a zip file called Response Plots to the file area for all to see.
> >
> > Thank you,
> > David.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi David,
> > >
> > > Nothing should really happen when you run the program except the motor should remain still and not run away.  It should be servoing.  That is if you push the motor by hand it should resist and try to return back to where it was.  The gain is probably very low so the response will be very poor but the idea is to see that functionally it is working.  A good thing to check at this stage is that the commutation is really working properly.  As you push the motor away the motor torque should increase up to the maximum we have set as the MaxOutput Parameter.  If we continue to push the motor further away, for example 2 revs, the torque should remain constant and in the same direction.  If the commutation is not working correctly the torque will vary or even reverse.  It is normal for a motor's torque to vary a bit (~10% torque ripple), but not more than that.
> > >
> > > My mistake on the ch4.  You are using ch0 so correct everything should be ch0.  I doubt if that would make any real difference.  It just wouldn't turn off the coil current after finding the index, but as soon as the servo is turned on, the servo will write new coil currents anyway.  I'm not sure why it made a difference for you.
> > >
> > > Making a "Move" on the Step Response Screen downloads all axis parameters from the Step, Config, and Filter Screens. So make sure they are all set to reasonable values and match what is in the HomeBrushless.c program.  An easy way to do this is to "Upload" the parameters from KFLOP to the Screens (after running the HomeBrushless.c program).  There is a Flash video that explains the interaction between the various ways to change parameters.  See:
> > >
> > > http://www.dynomotion.com/Help/FlashHelp/Parameters/index.html
> > >
> > > Plot the Response of a Move and post it so we can see it (one method is to Alt-Print-Screen, paste to Paint.exe, save as *.png file).  If you also save the raw data we can zoom, and plot the data ourselves in various ways.
> > >
> > > Don't really worry about the Init.c file at this point, but yes, after everything is working you can make one Init.c file that does everything, configures, enables, phasefinds, homes, etc...  Whatever you wish.
> > >
> > > Regards
> > > TK
> > >
> > >
> > >
> > >
> > >
> > > ________________________________
> > > From: daveymahomh600e <david.m.stevenson@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Friday, November 9, 2012 8:20 AM
> > > Subject: [DynoMotion] Re: Step by Step
> > >
> > >
> > >  
> > > Hi Tom,
> > >
> > > I loaded the HomeBrushless file and ran it. I couldn't tell if anything happened. Should there be any message on the console screen?
> > >
> > > I compared this new Homing file to other similar files and am wondering about the program line (43 in Notepad++) "Write3PH(ch4,0,0); // turn off the coil" should that be ch0?
> > >
> > > Anyway I ran the file and tried a move command on the Step Response screen and there was motion which ended with the servo twitching back and forth until disabling it. I changed line 43 to ch0 and ran it again and the plots on Step Response looked much more sensible.
> > >
> > > I know there is tuning to do, but does this HomeBrushless file get ultimately added to the init file?
> > >
> > > Thanks,
> > > David.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi David,
> > > >
> > > > That looks good.  Note the counts per cycle is not exact as it depends on how the motor moves which is dependent on friction and so forth, but clearly it should be 2 cycles per rev or 5000 counts/cycle.  So the relevant information to be extracted from all that is:
> > > >
> > > > invDistPerCycle=0.0002;
> > > > Commutationoffset=2987;
> > > >
> > > >
> > > > Simply putting those two number into the relevant axis configuration and zeroing the encoder at the index mark should allow the motor to commutate (generate torque) properly at any shaft angle.
> > > >
> > > > There are "HomeBrushless" examples that will do this and enable a servo loop.  So the next step is to try that and see if you can get the motor to servo (hold position).
> > > >
> > > > I think I have made the appropriate changes in the attached file.
> > > >
> > > > Regards
> > > > TK
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > From: daveymahomh600e <david.m.stevenson@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Thursday, November 8, 2012 5:56 PM
> > > > Subject: [DynoMotion] Re: Step by Step
> > > >
> > > >
> > > >  
> > > > Hi Tom,
> > > >
> > > > The new program seems to have cured that issue. Here are 3 reports...
> > > >
> > > > REPORT
> > > > ------
> > > > 0 Position = 1 PhaseAngle = 0.390600
> > > > 1 Position = 10001 PhaseAngle = 2.396800
> > > > 2 Position = 10002 PhaseAngle = 2.299000
> > > > 3 Position = 2 PhaseAngle = 0.255400
> > > > Counts per rev = 10000
> > > > Counts per cycle = 4985
> > > > Counts per cycle (rounded)= 4980
> > > > invDistPerCycle (rounded)= 0.000200803213
> > > > Commutation offset = 2978
> > > > Input Gain Specified = 1.000
> > > >
> > > > REPORT
> > > > ------
> > > > 0 Position = -1 PhaseAngle = 0.390400
> > > > 1 Position = 9999 PhaseAngle = 2.397600
> > > > 2 Position = 10000 PhaseAngle = 2.298800
> > > > 3 Position = 0 PhaseAngle = 0.255000
> > > > Counts per rev = 10000
> > > > Counts per cycle = 4982
> > > > Counts per cycle (rounded)= 4980
> > > > invDistPerCycle (rounded)= 0.000200803213
> > > > Commutation offset = 2979
> > > > Input Gain Specified = 1.000
> > > >
> > > > REPORT
> > > > ------
> > > > 0 Position = -1 PhaseAngle = 0.390500
> > > > 1 Position = 9999 PhaseAngle = 2.397300
> > > > 2 Position = 10000 PhaseAngle = 2.298900
> > > > 3 Position = 0 PhaseAngle = 0.255100
> > > > Counts per rev = 10000
> > > > Counts per cycle = 4983
> > > > Counts per cycle (rounded)= 4980
> > > > invDistPerCycle (rounded)= 0.000200803213
> > > > Commutation offset = 2979
> > > > Input Gain Specified = 1.000
> > > >
> > > > In each case, the motor shaft rotated once in each direction.
> > > >
> > > > Sooo, the next step is....
> > > >
> > > > Thank you very much,
> > > > David.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > >
> > > > >
> > > > > Hi David,
> > > > >
> > > > > It looks like the Index is not being detected every time.ÃÆ'‚  Because the Counts/Rev are always exactly a multiple of 10,000 it appears the encoder and index are working perfectly when it is detected.ÃÆ'‚  It just isn't detected every time.
> > > > >
> > > > > You might check the wire and voltages.ÃÆ'‚  If one of the + or - signals is not connected the signal can be erratic.ÃÆ'‚  Normally the index is not present so the + signal will be high (>3V) and the - signal low (< 0.4V). So you might check those voltages with a volt meter.
> > > > >
> > > > > It might be that the pulse is so short that the software loop misses it.ÃÆ'‚  Your encoder is fairly high resolution so the index pulse might be very small.ÃÆ'‚ 
> > > > >
> > > > >
> > > > > Now that I look at the AutoPhaseFind.c program I see that is actually only checking for the index every millisecond.ÃÆ'‚  I've attached a modified program that checks every time slice (180us) which is 5X faster.ÃÆ'‚  I've also slowed down the rotation speed about 2X.ÃÆ'‚  Please try that.
> > > > >
> > > > > Regards
> > > > > TK
> > > > >
> > > > >
> > > > >
> > > > > ________________________________
> > > > > From: David Stevenson <david.m.stevenson@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Thursday, November 8, 2012 4:24 PM
> > > > > Subject: RE: [DynoMotion] Re: Step by Step
> > > > >
> > > > >
> > > > > ÃÆ'‚ 
> > > > > ÃÆ'¯Â»Â¿
> > > > > Hi
> > > > > Tom,
> > > > > ÃÆ'‚ 
> > > > > Here are 4
> > > > > reports, which look a lot better than most have...
> > > > > ÃÆ'‚ 
> > > > > After each
> > > > > report I noted how many turns (revs) the shaft made... so many in one direction
> > > > > and then so many in the opposite direction. I didn't catch the number for the
> > > > > first set on the first test. I know the encoder is a 2500 ppr, so I expect 10000
> > > > > for a full turn of the shaft.
> > > > > ÃÆ'‚ 
> > > > > REPORT
> > > > > ------
> > > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  0
> > > > > PhaseAngle = 0.416000
> > > > > 1 Position =ÃÆ'‚  10000 PhaseAngle = 2.455000
> > > > > 2
> > > > > Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  1 PhaseAngle = 0.197000
> > > > > 3 Position =
> > > > > -109999 PhaseAngle = -21.803000
> > > > > Counts per rev =ÃÆ'‚  10000
> > > > > Counts per
> > > > > cycle =ÃÆ'‚ ÃÆ'‚  4904
> > > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > > 4900
> > > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000204081633
> > > > > Commutation offset
> > > > > =ÃÆ'‚ ÃÆ'‚  2822
> > > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > > ÃÆ'‚ 
> > > > > ? and 10
> > > > > turns
> > > > > ÃÆ'‚ 
> > > > > REPORT
> > > > > ------
> > > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  -1
> > > > > PhaseAngle = 0.417000
> > > > > 1 Position = 119999 PhaseAngle = 24.455000
> > > > > 2
> > > > > Position =ÃÆ'‚  39998 PhaseAngle = 8.196000
> > > > > 3 Position =ÃÆ'‚  19998
> > > > > PhaseAngle = 4.196000
> > > > > Counts per rev = 120000
> > > > > Counts per cycle
> > > > > =ÃÆ'‚ ÃÆ'‚  4992
> > > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > > 4990
> > > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000200400802
> > > > > Commutation offset
> > > > > =ÃÆ'‚ ÃÆ'‚  2872
> > > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > > ÃÆ'‚ 
> > > > > 12 and 10
> > > > > turns
> > > > > ÃÆ'‚ 
> > > > > REPORT
> > > > > ------
> > > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  2
> > > > > PhaseAngle = 0.417000
> > > > > 1 Position =ÃÆ'‚  60001 PhaseAngle = 12.454000
> > > > > 2
> > > > > Position =ÃÆ'‚  50001 PhaseAngle = 10.198000
> > > > > 3 Position =ÃÆ'‚  30002
> > > > > PhaseAngle = 6.198000
> > > > > Counts per rev =ÃÆ'‚  59999
> > > > > Counts per cycle
> > > > > =ÃÆ'‚ ÃÆ'‚  4985
> > > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚ 
> > > > > 4980
> > > > > invDistPerCycle (rounded)=ÃÆ'‚  0.000200803213
> > > > > Commutation offset
> > > > > =ÃÆ'‚ ÃÆ'‚  2868
> > > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > > ÃÆ'‚ 
> > > > > 6 and 10
> > > > > turns
> > > > > ÃÆ'‚ 
> > > > > REPORT
> > > > > ------
> > > > > 0 Position =ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚  0
> > > > > PhaseAngle = 0.417000
> > > > > 1 Position =ÃÆ'‚  39999 PhaseAngle = 8.454000
> > > > > 2
> > > > > Position = -40001 PhaseAngle = -7.802000
> > > > > 3 Position = -60002 PhaseAngle =
> > > > > -11.802000
> > > > > Counts per rev =ÃÆ'‚  39999
> > > > > Counts per cycle =ÃÆ'‚ ÃÆ'‚ 
> > > > > 4977
> > > > > Counts per cycle (rounded)=ÃÆ'‚ ÃÆ'‚  4980
> > > > > invDistPerCycle
> > > > > (rounded)=ÃÆ'‚  0.000200803213
> > > > > Commutation offset =ÃÆ'‚ ÃÆ'‚ 
> > > > > 2868
> > > > > Input Gain Specified =ÃÆ'‚  1.000
> > > > > ÃÆ'‚ 
> > > > > 4 and 10
> > > > > turns
> > > > > ÃÆ'‚ 
> > > > > Here are
> > > > > the settings I used for the APF.c program...
> > > > > ÃÆ'‚ 
> > > > > #define
> > > > > PWM_CHAN 8ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // which pair of PWM channels used
> > > > > #define
> > > > > ENCODER_CHANÃÆ'‚ 8ÃÆ'‚ ÃÆ'‚ // which encoder we are connected to
> > > > > #define
> > > > > ENCODER_GAIN 1 ÃÆ'‚ ÃÆ'‚ // Set to -1 if desired to reverse axis
> > > > > direction
> > > > > #define AMPLITUDE 10ÃÆ'‚ ÃÆ'‚  ÃÆ'‚ ÃÆ'‚ // Set how hard to
> > > > > drive the coils pwm counts
> > > > > #define Z_BIT_NUMBER 66ÃÆ'‚ ÃÆ'‚ // What bit the
> > > > > Z index is connected to
> > > > > #define CLAMP_VOLTAGE 85ÃÆ'‚  ÃÆ'‚ // volts - set a
> > > > > few volts higher than your supply
> > > > > #define
> > > > > AXIS_CHANÃÆ'‚ 0ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // Axis channel
> > > > > to be used and configured
> > > > > #define Ncycles 4ÃÆ'‚ ÃÆ'‚ ÃÆ'‚ // don't change
> > > > > this
> > > > > ÃÆ'‚ 
> > > > > Thank
> > > > > you,
> > > > > David.
> > > > > ÃÆ'‚ 
> > > > > ÃÆ'‚ 
> > > > >
Group: DynoMotion Message: 6025 From: Tom Kerekes Date: 11/10/2012
Subject: Re: Step by Step
Hi David,

Excellent.  That looks quite good for a start.

The next step is tuning which involves: PID tuning, adding a low pass filter, increasing max output, finding your max Velocity, Acceleration, and Jerk, Reducing Max Following error to fault on any problem.

Please read those threads on tuning and let us know how much makes sense.  Of course the goal is to move at the speeds and velocities needed with your required accuracy.  Note in your current plots the max following error is about 160 encoder counts.  You should convert this to real distance to understand if this is acceptable.  Also note that only ~16 output counts and ~ 1Amp is used by the motor so you have the potential of much higher acceleration.  Test longer "size" moves to get to higher velocities.

HTH
Regards
TK